import request from '@/sheep/request';
import $platform from '@/sheep/platform';

export default {
    getAppAccount: (type) =>
        request({
            url: '/no-auth/app/account/' + type,
            method: 'GET'
        }),
    generateVerifiedCode: (type) =>
        request({
            url: '/no-auth/verified/code/generate',
            method: 'GET'
        }),
    getHomeConfig: () =>
        request({
            url: '/no-auth/home/home-cfg',
            method: 'GET',
            custom: {
                showLoading: false,
                showError: false,
            },
        }),
    getHomeMedia: (type) =>
        request({
            url: '/no-auth/home/media',
            method: 'GET',
            params: { type },
            custom: {
                showLoading: false,
                showError: false,
            },
        }),
    getHomeTypes: () =>
        request({
            url: '/no-auth/home/types',
            method: 'GET',
            custom: {
                showLoading: false,
                showError: false,
            },
        }),
    getHomeContentByType: (type, city) =>
        request({
            url: `/no-auth/home/type/${type}`,
            method: 'GET',
            params: { city },
            custom: {
                showLoading: false,
                showError: false,
            },
        }),
    getHomeDetail: (type, id) =>
        request({
            url: `/no-auth/home/detail/${type}`,
            method: 'GET',
            params: { id },
            custom: {
                showLoading: false,
                showError: false,
            },
        }),
    bookHomestay: (data) =>
        request({
            url: '/no-auth/homestay/book',
            method: 'POST',
            data,
            custom: {
                showLoading: true,
                showSuccess: true,
                successMsg: '预订成功'
            },
        }),
    addHomestayOrder: (data) =>
        request({
            url: '/h5/homestay/add',
            method: 'POST',
            data,
            custom: {
                showLoading: true,
                showSuccess: true,
                successMsg: '下单成功'
            },
        }),
    prepayHomestay: (orderId) =>
        request({
            url: `/h5/prepay/homestay/${orderId}`,
            method: 'POST',
            custom: {
                showLoading: true,
                showError: true,
                loadingMsg: '正在调起支付...'
            },
        }),
    getHomestayOrders: (params) =>
        request({
            url: '/h5/homestay/page',
            method: 'GET',
            params,
            custom: {
                showLoading: false,
                showError: true,
            },
        }),
    followContent: (data) =>
        request({
            url: '/h5/member/follow',
            method: 'POST',
            data,
            custom: {
                showLoading: true,
                showSuccess: true,
                successMsg: '关注成功'
            },
        }),
    unfollowContent: (data) =>
        request({
            url: '/h5/member/follow',
            method: 'POST',
            data,
            custom: {
                showLoading: true,
                showSuccess: true,
                successMsg: '取消关注成功'
            },
        }),
    
    // 获取关注列表
    getFollowList: (params) =>
        request({
            url: '/no-auth/home/type/1',
            method: 'GET',
            params,
            custom: {
                showLoading: false,
                showError: true,
            },
        }),
    
    // 取消关注 - 通过关注ID
    unfollowById: (followId) =>
        request({
            url: `/h5/member/unfollow/${followId}`,
            method: 'GET',
            custom: {
                showLoading: true,
                showSuccess: true,
                successMsg: '取消关注成功'
            },
        }),
};
